#!/bin/sh
################################################################################
# dbus
################################################################################
. /etc/rc.d/functions

start() {
    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/dbus] Starting..."

    if [ -e "/usr/bin/dbus-uuidgen" ] ; then
        /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/dbus] Initializing dbus-uuid..."
        if [ ! -e "/var/lib/dbus" ] ; then
            mkdir -p -m 0755 /var/lib/dbus
        fi
        /usr/bin/dbus-uuidgen > /var/lib/dbus/machine-id
        chmod 0644 /var/lib/dbus/machine-id
    fi

    if [ -e "/usr/bin/dbus-daemon" ] && [ -e "/etc/dbus-1/system.conf" ] ; then
        /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/dbus] Starting dbus daemon..."

        if [ ! -e "/var/run/dbus" ] ; then
            mkdir -p -m 0755 /var/run/dbus
        fi

        /usr/bin/dbus-daemon --config-file=/etc/dbus-1/system.conf

    fi

    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/dbus] Started with return code=0..."

    return 0

}

stop() {
    mm_message_output info "stopping dbus ..."
}

case $1 in
    start) start ;;
    stop)  stop  ;;
esac

exit 0
